package com.bawei.library_mvi.model

import androidx.lifecycle.ViewModel
import com.bawei.library_mvi.IIntent
import kotlinx.coroutines.channels.Channel

/**
 * @Author : yaotianxue
 * @Time : On 2023/6/19 16:00
 * @Description : BaseViewModel
 */
abstract class BaseViewModel<I:IIntent> :ViewModel(),IModel<I>{
    private val _intents = Channel<I>(Channel.UNLIMITED)//通道
    //重写父类的intents
    override val intents: Channel<I>
        get() = _intents
    init {
        handleIntent()
    }
    /**
     * 处理用户发送过来的intent
     */
    abstract fun handleIntent()
}